package com.heba.greenmulu.diary;

import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.heba.config.CommonConfig;
import com.heba.fragment.diary.DiaryFragment;
import com.heba.greenmulu.BaseActivity;
import com.heba.greenmulu.R;

/**
 * 检索相关标签的日记贴列表
 * Created by jason on 2020/5/20.
 */
public class ItemDiaryTagSearchActivity extends BaseActivity {

    public static final int TYPE_DIARY_TAG = 1;

    private String keyWord;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_diary_tag_search);
        initTopbar();
        findViewById();
        initView();
        initFragment();
    }

    @Override
    protected void findViewById() {

    }

    @Override
    protected void initView() {
        Bundle bundle = getIntent().getExtras();
        if (null != bundle) {
            keyWord = bundle.getString(CommonConfig.KEYWORD, "");
        }

        txt_title.setText(keyWord);
    }

    private void initFragment() {
        replaceFragment(R.id.linear_fragment, DiaryFragment.newInstance(TYPE_DIARY_TAG, keyWord));
    }

    public void replaceFragment(int viewId, Fragment fragment) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction().replace(viewId, fragment).commit();
    }
}
